package com.xs.tool.common.result;

public class Response  {

	/****
	 * 成功响应Msg中的信息
	 **/
	private final static String SUCCESS = "success";

	/****
	 * 失败响应Msg中的信息
	 **/
	private final static String FAILED = "failed";


	public static <T> Result<T> success() {
		return new Result<T>().setCode(ResultsCode.SUCCESS).setMsg(SUCCESS);
	}


	public static <T> Result<T> success(T data) {
		return new Result<T>().setCode(ResultsCode.SUCCESS).setMsg(SUCCESS).setData(data);
	}


	public static <T> Result<T> error(ResultsCode resultsCode) {
		return new Result<T>().setCode(resultsCode.code).setMsg(resultsCode.message);
	}


	public static <T> Result<T> error(String mesage) {
		return new Result<T>().setMsg(mesage).setCode(ResultsCode.FAIL);
	}


	public static <T> Result<T> error(String mesage, ResultsCode resultsCode) {
		return new Result<T>().setMsg(mesage).setCode(resultsCode.code);
	}

	public static <T> Result<T> error() {
		return new Result<T>().setCode(ResultsCode.FAIL).setMsg(FAILED);
	}


}
